<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//测试控制器
class DengluController extends Controller{

	//构造函数
	// public function __init()
	// {
	// }
	
    // 登录前台首页
    public function index(){

	     if(IS_POST){
		     	$username = Q('post.useremail');
		     	$password = Q('post.userpassword','','md5');
		     	$model = new \Common\Model\User;
	     	    //从数据库获得用户数据
				$data = $model->where("useremail='{$username}'")->find();
				if(!$data) View::error('用户名或者密码错误');
				//三、判断密码是否正确
				if($data['userpassword']!= $password) View::error('用户名或者密码错误');
				//四、登陆成功
				$_SESSION['uid'] = $data['uid'];
				$_SESSION['username'] = $data['useremail'];
				View::success('登陆成功',U('Index/index'));
	     }


       View::make();
    }
}
